package 注解;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;

//InheritableSon 类只是继承于 InheritableFather，  
public class InheritableSon extends InheritableFather {
	public InheritableSon() {
		super();// 调用父类的构造函数
		// InheritableSon类是否具有 Inheritable Annotation
		System.out.println("InheritableSon:" + InheritableSon.class.isAnnotationPresent(Inheritable.class));
	}

	public static void main(String[] args) {
		InheritableSon is = new InheritableSon();
	}
}

//自定义的Annotation
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface Inheritable{}

@Inheritable
class InheritableFather {
	public InheritableFather() {
		//InheritableBase是否具有 Inheritable Annotation
		System.out.println("InheritableFather:"+InheritableFather.class.isAnnotationPresent(Inheritable.class));
	}
}
